package com.framework.common.sms;

import com.framework.common.config.SystemConfigName;
import com.framework.common.sms.SmsResponse;
import com.framework.common.sms.SmsServiceConfig;
import com.framework.common.sms.SmsServiceFactory;
import com.framework.common.sms.interfaces.IAdvanceSmsService;
import com.framework.common.utils.QuickHelper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;
import java.util.Map;

@Service
public class CloudSmsService{

    /**
     * 发送短信
     * @param mobs 手机号码，用逗号分割
     * @param validateCode 验证码
     * @return
     */
    public SmsResponse send_validate_code(String mobs, String validateCode){
        String smsSdkName=QuickHelper.getConfigString(SystemConfigName.SMS_SDK_NAME);
        IAdvanceSmsService<SmsResponse, SmsServiceConfig> service = SmsServiceFactory.create(smsSdkName);
        SmsServiceConfig config = QuickHelper.getConfigValue(SystemConfigName.SMS_SDK_CONFIG,SmsServiceConfig.class);
        service.init(config);
        Map<String,String> maps = new LinkedHashMap<>();
        maps.put("default",validateCode);
        SmsResponse res = service.send(mobs,maps);
        return  res;
    }
}